import Vue from "vue";
import VueRouter from 'vue-router';

import bottomList from "../components/bottomList/bottomList"
import topList from "../components/topList/topList"
import Carousel from "../components/Carousel/Carousel"
import CarouselList from "../components/Carousel/CarouselList"
import CarouselListtoo from "../components/Carousel/CarouselListtoo"
import listIndex from "../view/information/listIndex"
import middleList from "../view/information/middleList"
import homeList from "../view/homeList/homeList"
import donghua from "../view/test/donghua"
import select from "../view/test/select"
import Searchcontent from "../view/information/Searchcontent"
import teachingReform from "../view/information/teachingReform"
import xinwenzhongxin from "../view/homeList/xinwenzhongxin"
import jiaoyanjiaogai from "../view/information/jiaoyanjiaogai"
import shidian from "../view/information/shidian"
import zhuanti from "../view/information/zhuanti"
import renwu from "../view/information/renwu"
import tushuo from "../view/information/tushuo"
import imageList from "../view/information/imageList"

Vue.use(VueRouter)
export default new VueRouter({
    routes:[
        {
            // 首页
            path: '/',
            component: homeList,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
            // redirect: '/listIndex',
        },
        {
            // 底部导航栏
            path: '/bottomList',
            name: 'bottomList',
            component: bottomList,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            // 专题？热点专题
            path: '/zhuanti',
            name: 'zhuanti',
            component: zhuanti,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            // 图说详情
            path: '/imageList',
            name: 'imageList',
            component: imageList,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            // 资讯 人物
            path: '/renwu',
            name: 'renwu',
            component: renwu,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            // 资讯 图说
            path: '/tushuo',
            name: 'tushuo',
            component: tushuo,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            // 教研教改
            path: '/jiaoyanjiaogai',
            name: 'jiaoyanjiaogai',
            component: jiaoyanjiaogai,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            // 资讯视点
            path: '/shidian',
            name: 'shidian',
            component: shidian,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            // 动画
            path: '/donghua',
            name: 'donghua',
            component: donghua
        },
        {
            // 动画
            path: '/select',
            name: 'select',
            component: select
        },
        {
            // 搜索详情页
            path: '/Searchcontent',
            name: 'Searchcontent',
            component: Searchcontent,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            // 顶部导航栏
            path: '/topList',
            name: 'topList',
            component: topList,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            //
            path: '/middleList',
            name: 'middleList',
            component: middleList,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            // 首页
            path: '/homeList',
            name: 'homeList',
            component: homeList,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            //
            path: '/listIndex',
            name: 'listIndex',
            component: listIndex,
            meta:{
                title:'广西八桂职教网-有职教的地方就有我们!'
            }
        },
        {
            // 轮播图
            path: '/Carousel',
            name: 'Carousel',
            component: Carousel,
            meta: { requireAuth: true }// 添加该字段，表示进入这个路由是需要登录的 ,
        },
        {
            // 多列轮播图
            path: '/CarouselList',
            name: 'CarouselList',
            component: CarouselList,
            meta: { requireAuth: true }// 添加该字段，表示进入这个路由是需要登录的 ,
        },
        {
            // 多列轮播图2
            path: '/CarouselListtoo',
            name: 'CarouselListtoo',
            component: CarouselListtoo,
            meta: { requireAuth: true }// 添加该字段，表示进入这个路由是需要登录的 ,
        },
        {
            // 教研教改
            path: '/teachingReform',
            name: 'teachingReform',
            component: teachingReform,
            meta: { requireAuth: true }// 添加该字段，表示进入这个路由是需要登录的 ,
        },
        {
            // 新闻中心
            path: '/xinwenzhongxin',
            name: 'xinwenzhongxin',
            component: xinwenzhongxin,
            meta: { requireAuth: true }// 添加该字段，表示进入这个路由是需要登录的 ,
        }
    ],
})
// //这个方法是为了每个页面添加属于自己的title
// router.beforeEach((to,from,next)=>{
//     if(to.meta.title){
//         document.title=to.meta.title
//     }
//     next()
// })


const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
    return originalReplace.call(this, location).catch(err => err);
};
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
